using System;
using UnityEngine;
using UnityEngine.Events;

namespace Voodoo.Utils
{
	public class DelayAction : Delay
	{
		public Action OnActionStart;

		public Action OnActionCompleted;

		private Action m_Action;

		public DelayAction SetAction(Action action)
		{
			m_Action = action;
			return this;
		}

		public DelayAction SetAction(UnityAction action)
		{
			m_Action = action.Invoke;
			return this;
		}

		public new DelayAction SetDelay(float delay)
		{
			_delay = delay;
			return this;
		}

		protected override void OnTimeOut()
		{
			OnDelayCompleted?.Invoke();
			OnActionStart?.Invoke();
			m_Action?.Invoke();
			OnActionCompleted?.Invoke();
			UnityEngine.Object.Destroy(base.gameObject);
		}
	}
}
